<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>分享云微商城</title>

    <!-- css -->
    <link href="/mall/Public/Resource/css/bootstrap.min.css" rel="stylesheet">
    <link href="/mall/Public/Resource/css/all.css" rel="stylesheet">
    <script type="text/javascript" src="//libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="/mall/Public/Resource/js/common.js"></script>
    <script language='javascript' src='/mall/Public/Resource/js/jquery.cookie.js'></script>
    <script language='javascript' src='/mall/Public/Resource/js/wechat-useragent.js'></script>
</head>
<body>
<div class="navbar-default" role="navigation">
    <div class="container-fluid">
        <ul class="nav">
            <li><a href="/mall/Public/index.php">微商场</a></li>
            <li><a href="/mall/Public/index.php/shoppingcart/index">购物车</a></li>
            <li><a href="/mall/Public/index.php/index/about">分享云简介</a></li>
        </ul>
    </div>
</div>
<div class="main">
    <div class="container-fluid">
        <div class="row">
            <a class="col-xs-12 product-list">
                <div class="product-img">
                    <div>
                        <img src="<?php echo ($image); ?>" alt="">
                    </div>

                </div>
                <div class="product-nam">
                    <p><?php echo ($name); ?></p>
                    <p>
                        <?php if($trueprice != $saleprice): ?><del><?php echo ($trueprice); ?></del><?php endif; ?>
                        <span><?php echo ($saleprice); ?></span>

                        <?php if($trueprice != $saleprice): ?><span>仅限11月1日~11月3日</span><?php endif; ?>
                        <?php if($trueprice == $saleprice): ?><span></span><?php endif; ?>
                    </p>
                </div>
            </a>
            <div class="col-xs-12 product-list">
                <ul class="nav">
                    <li><a href="#information">商品信息</a></li>
                    <li><a href="#param">规格参数</a></li>
                    <li><a href="#service">包装售后</a></li>
                </ul>
                <div class="product-detail">
                    <label id="information">1、商品信息</label>
                    <div class="detail"><?php echo ($intro); ?> </div>
                    <label id="param">2、规格参数</label>
                    <div class="detail"><?php echo ($specification); ?></div>
                    <label id="service">3、安装售后</label>
                    <div class="detail"><?php echo ($service); ?></div>
                    <label id="intall_label">4、安装参数确认</label>
                    <div id="intall_div" class="detail"><?php echo ($intall); ?></div>
                </div>
            </div>
        </div>
    </div>
    <div class="footer" id="footer_norm" >
        <ul class="nav">
            <li class="my-cart"><a href="/mall/Public/index.php/shoppingcart/index" ><i class="glyphicon glyphicon-shopping-cart"><span style="display: none" class="badge" id="cartnum0">1</span></i> 购物车</a></li>
            <li class="btn-red"><a  onclick="buynow()">马上购买</a></li>
            <li class="btn-org"><a onclick="shoppingcart()">加入购物车</a></li>
        </ul>
    </div>


    <!-- 立即购买底部样式-->
    <div class="footer"  style="display: none;" id="footer_buynow">
        <ul class="nav nav-one">
            <li class="btn-red"><a href="#" onclick="buynowpay()">马上购买</a></li>
        </ul>
    </div>
    <div class="modal" hidden="hidden" style="display: none;" id="footer1_buynow">
        <div class="modal-body">
            <div class="modal-content">
                <a class="glyphicon glyphicon-remove-sign"  onclick="closenow()"></a>
                <div class="content" id="specification_div1">
                    <dl>
                        <dt>左右开规格</dt>
                        <dd  id="left_open1"><a href="#" onclick="specification('left_open1')">左开</a></dd>
                        <dd id="right_open1"><a href="#" onclick="specification('right_open1')">右开</a></dd>
                    </dl>
                    <dl>
                        <dt>内外开规格</dt>
                        <dd  id="in_open1"><a href="#" onclick="specification('in_open1')">内开</a></dd>
                        <dd id="out_open1"><a href="#" onclick="specification('out_open1')">外开</a></dd>
                    </dl>
                </div>
                <div class="modal-footer">
                    <div style="float:left">数量</div>
                    <div class="num" style="float: right">
                        <input class="sub" name="" type="button" value="-" onclick="subnum(event);" />
                        <input class="text_box" name="goodnum" id="goodnum_buynow" type="text" value="1" onchange="setTotal(event.target)"/>
                        <input class="add" name="" type="button" value="+" onclick="addnum(event);" />
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- 加入购物车底部样式-->
    <div class="footer" style="display: none;" id="footer_cart">
        <ul class="nav nav-tow">
            <li class="my-cart"><a href="/mall/Public/index.php/shoppingcart/index" ><i class="glyphicon glyphicon-shopping-cart" ><span style="display: none" class="badge" id="cartnum">1</span></i>购物车 </a></li>
            <li class="btn-red"><a href="#" onclick="addtocart()">加入购物车</a></li>
        </ul>
    </div>
    <div class="modal" style="display: none;" id="footer1_cart">
        <div class="modal-body">
            <div class="modal-content">
                <a class="glyphicon glyphicon-remove-sign" onclick="closenow()"></a>
                <div class="content" id="specification_div">
                    <dl>
                        <dt>左右开规格</dt>
                        <dd  id="left_open"><a href="#" onclick="specification('left_open')">左开</a></dd>
                        <dd id="right_open"><a href="#" onclick="specification('right_open')">右开</a></dd>
                    </dl>
                    <dl>
                        <dt>内外开规格</dt>
                        <dd  id="in_open"><a href="#" onclick="specification('in_open')">内开</a></dd>
                        <dd id="out_open"><a href="#" onclick="specification('out_open')">外开</a></dd>
                    </dl>
                </div>
                <div class="modal-footer">
                    <div style="float:left">数量</div>
                    <div class="num" style="float: right">
                        <input class="sub" name="" type="button" value="-" onclick="subnum(event);" />
                        <input class="text_box" name="goodnum" id="goodnum" type="text" value="1" onchange="setTotal(event.target)"/>
                        <input class="add" name="" type="button" value="+" onclick="addnum(event);" />
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>


</div>



<script>
    //左右规格
    var left_right = '';
    var in_out = '';
    $.removeCookie('buynow',{ path: '/' });
    initshoppingcart();

    if('666' == "<?php echo ($lockid); ?>" || '777' == "<?php echo ($lockid); ?>"){
        left_right = 'left';
        in_out = 'in';
        document.getElementById('specification_div').style.visibility = 'hidden';//visible
        document.getElementById('specification_div1').style.visibility = 'hidden';//visible
        document.getElementById('intall_div').style.display="none";
        document.getElementById('intall_label').style.display="none";
    }


     function closenow() {
         document.getElementById('footer_norm').style.display="";
         document.getElementById('footer_buynow').style.display="none";
         document.getElementById('footer1_buynow').style.display="none";
         document.getElementById('footer_cart').style.display="none";
         document.getElementById('footer1_cart').style.display="none";


         document.getElementById('right_open').className = "";
         document.getElementById('left_open').className = "";
         document.getElementById('out_open').className = "";
         document.getElementById('in_open').className = "";
         document.getElementById('right_open1').className = "";
         document.getElementById('left_open1').className = "";
         document.getElementById('out_open1').className = "";
         document.getElementById('in_open1').className = "";

         left_right = '';
         in_out = '';

         if('666' == "<?php echo ($lockid); ?>" || '777' == "<?php echo ($lockid); ?>") {
             left_right = 'left';
             in_out = 'in';
         }
     }

    function buynow() {
         document.getElementById('footer_norm').style.display="none";
         document.getElementById('footer_buynow').style.display="";
         document.getElementById('footer1_buynow').style.display="";

     }

     function shoppingcart() {

         document.getElementById('footer_norm').style.display="none";
         document.getElementById('footer_cart').style.display="";
         document.getElementById('footer1_cart').style.display="";


     }

     function buynowpay() {

         if(left_right == '' || in_out == ''){
             alert("请选择规格");
             return;
         }

         var t = document.getElementById('goodnum_buynow');
         var num = t.value;
         var key = 'buynow-'+"<?php echo ($lockid); ?>"+'-'+left_right+'-'+in_out;
         $.cookie('buynow',key,{ expires: 7, path: '/' });
         $.cookie(key,num,{ expires: 7, path: '/' });

         window.location = "/mall/Public/index.php/order/index";
     }


    function specification(id) {

        document.getElementById(id).className = "in";

        //购物车
        if(id == 'left_open' ){
            left_right = 'left';
            document.getElementById('right_open').className = "";
        }
        if(id == 'right_open'){
            left_right = 'right';
            document.getElementById('left_open').className = "";
        }
        if(id == 'in_open'){
            in_out = 'in';
            document.getElementById('out_open').className = "";
        }
        if(id == 'out_open'){
            in_out = 'out';
            document.getElementById('in_open').className = "";
        }

        //立即购买
        if(id == 'left_open1' ){
            left_right = 'left';
            document.getElementById('right_open1').className = "";
        }
        if(id == 'right_open1'){
            left_right = 'right';
            document.getElementById('left_open1').className = "";
        }
        if(id == 'in_open1'){
            in_out = 'in';
            document.getElementById('out_open1').className = "";
        }
        if(id == 'out_open1'){
            in_out = 'out';
            document.getElementById('in_open1').className = "";
        }

    }


     function addtocart() {
         var t = document.getElementById('goodnum');
         var num = t.value;

         if(left_right == '' || in_out == ''){
             alert("请选择规格");
             return;
         }

         var key = "<?php echo ($lockid); ?>"+'-'+left_right+'-'+in_out;

         var oldnum = $.cookie(key);

//         alert('存前商品数量:'+oldnum+ '  添加数量:'+num+'  key ='+key);

         if(isOwnEmpty(oldnum) || typeof(oldnum) == undefined){
             var goodkeys = $.cookie('goodkeys');
             if(isOwnEmpty(goodkeys) || typeof(goodkeys) == undefined){
                 $.cookie('goodkeys',key,{ expires: 7, path: '/' });
//                 alert('0商品key:'+$.cookie('goodkeys'));
             }else{
                 var tempkey = goodkeys+'@'+key;
                 $.cookie('goodkeys',tempkey,{ expires: 7, path: '/' });
//                 alert('1商品key:'+$.cookie('goodkeys'));
             }
             $.cookie(key,num,{ expires: 7, path: '/' });
//             alert('0存后商品数量:'+$.cookie(key)+'  key = '+key);
         }else{
             var tempnum = parseInt(num)+parseInt(oldnum);
             $.cookie(key,tempnum,{ expires: 7, path: '/' });
//             alert('1存后商品数量:'+$.cookie(key)+'  key = '+key+"\n"+"添加后数量:"+tempnum);
         }

         initshoppingcart();



     }

     function initshoppingcart(){
         var temp = $.cookie('goodkeys');
         if(isOwnEmpty(temp) || typeof temp == undefined || temp == ""){
             return;
         }

         var keys = temp.split('@');
         var totalnum = 0;
         if(!isOwnEmpty(keys) && typeof keys != undefined && keys != ""){
             for(var i=0;i<keys.length;i++) {
                 var key = keys[i];
//                 alert("key="+key + "  num="+parseInt($.cookie(key)));
                 totalnum = totalnum + parseInt($.cookie(key));
             }
         }

//         alert("totalnum="+totalnum);
         if(totalnum != 0){
             document.getElementById('cartnum').innerHTML = totalnum;
             document.getElementById('cartnum0').innerHTML = totalnum;
             document.getElementById('cartnum').style.display = '';
             document.getElementById('cartnum0').style.display = '';
         }else{
             document.getElementById('cartnum').style.display = 'none';
             document.getElementById('cartnum0').style.display = 'none';
         }

     }

    function subnum(e){
        var p = e.target.parentNode;
        var t = p.getElementsByClassName('text_box')[0];
        t.value = parseInt(t.value)-1;
        setTotal(t);
    }

    function addnum(e){
        var p = e.target.parentNode;
        var t = p.getElementsByClassName('text_box')[0];
        t.value = parseInt(t.value)+1;
        setTotal(t);
    }

    function setTotal(t){
        var tt = t.value;
        if(parseInt(tt)<=0||isNaN(tt)){
            t.value = 1;
        }
    }


</script>



</body>
</html>